package com.sinosoft.perfect.system._worksite.service;

import java.sql.SQLException;
import java.util.List;

import com.sinosoft.perfect.system._.po.TWorksite;
import com.sinosoft.perfect.system._.util.Producer;
import com.sinosoft.perfect.system._worksite.dao.IWorksiteDAO;

public class WorksiteServiceImpl implements IWorksiteService {

	private IWorksiteDAO worksiteDAO;

	@Override
	public void deleteTWorksiteByPK(TWorksite tworksite) throws SQLException {
		worksiteDAO.updateTUnitForClearWorksiteId(tworksite.getWorksiteId());
		worksiteDAO.deleteTWorksiteByPK(tworksite);
	}

	@Override
	public String insertByTWorksite(TWorksite tworksite) throws SQLException {
		String id = Producer.generateIdOfTen();
		tworksite.setWorksiteId(id);
		worksiteDAO.insertByTWorksite(tworksite);
		return id;
	}

	@Override
	public List<TWorksite> selectByTWorksite(TWorksite tworksite) throws SQLException {
		return worksiteDAO.selectByTWorksite(tworksite);
	}

	@Override
	public void updateTWorksite(TWorksite tworksite) throws SQLException {
		worksiteDAO.updateTWorksite(tworksite);
	}

	/**
	 * set/get
	 */

	public void setWorksiteDAO(IWorksiteDAO worksiteDAO) {
		this.worksiteDAO = worksiteDAO;
	}
}
